<template>
	<view class="content">
		<view class="login_header">
			<view class="fanhui" @click="go_back"><tui-icon name="arrowleft" :size="30" color="#333"></tui-icon></view>
		</view>
		<view class="login_more">
			<view class="title">登录获取更多</view>
			<view class="ipt uni-flex uni-flex-align">
				<input type="text" placeholder="手机号" placeholder-class="inp_input" v-model="mobile" @input="get_int">
			</view>
			<view class="ipt uni-flex uni-flex-align uni-flex-bt">
				<input type="password" placeholder="密码" placeholder-class="inp_input" v-model="pwd" @input="get_int" >
			</view>
			<view class="uni-flex uni-flex-align uni-flex-end forget" >
				
			</view>
			<view class="btn-info">
			  <view class="btn" style="opacity:1" @click="tui.dianji(login)">
			    <text>登录</text>
			  </view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				title: 'Hello',
				mobile:'',
				is_check:1,
				is_hei:false,
				pwd:'',
				is_btn:false,
				is_xian:false,
				type_inp:'password',
				isWeiXin:false,
			}
		},
		onLoad() {
			this.checkWeiXin()
		},
		methods: {
			go_back(){
				uni.navigateBack()
			},
			checkWeiXin() {
				let userAgent = navigator.userAgent;
				if (userAgent.includes("MicroMessenger")) {
					this.isWeiXin = true
				} else {
					this.isWeiXin = false
				}
				console.log(this.isWeiXin)
			},
			getXian(){
				this.is_xian=!this.is_xian
				if(this.is_xian){
					this.type_inp = 'text'
				}else{
					this.type_inp = 'password'
				}
			},
			get_int(){
				if(this.mobile==''||this.pwd==''){
					this.is_hei = false
				}else{
					this.is_hei = true
				}
			},
			
			go_url(e){
				let that = this
				that.tui.href(e)
			},
			login() {
				let that = this
				if (that.mobile == '') {
					that.tui.toast('手机号不能为空');
					return;
				}
				if (that.pwd == '') {
					that.tui.toast('密码不能为空');
					return;
				}
				that.is_btn = true
				let data ={
					phone: that.mobile,
					password: that.pwd
				}
				that.tui.request("api.login/in", "POST", data, false, false, false).then((res) => {
					that.tui.toast(res.info)
					if(res.code==1){
						uni.setStorageSync('d_token', res.data.token)
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/home/home'
							})
						},1000)
					}
				}).catch((res) => {
					that.is_btn = false
				})
			},
			
			
		}
	}
</script>

<style lang="scss">
	page{background: #fff;}
	.login_header{position: fixed;top: 0;left: 0;width: 100%;padding: 20rpx 0 0;
		.fanhui{padding-left: 20rpx;}
	}
	.login_more{padding: 200rpx 50rpx 30rpx;
		.title{font-weight: bold;font-size: 40rpx}
		.wenben{color: #808080;font-weight: bold;margin: 40rpx 0 30rpx;}
	}
	.ipt{border-bottom: 1px solid #c0c0c0;padding: 20rpx 0;margin-top: 40rpx;
		.left{font-weight: bold;font-size: 32rpx;}
		input{padding-left: 20rpx;border: transparent;width: 560rpx;}
		.yanjing{
			width: 50rpx;height: 50rpx;
		}
	}
	.inp_input{color: #bfbfbf;font-size: 26rpx;}
	.forget{margin-top: 20rpx;color: #808080}
	.btn{background: #e6e6e6;margin:100rpx 0rpx 40rpx;color: #fff;}
	.btn.black{background: #212121;}
	.wenben_1{font-weight: bold;font-size: 32rpx;text-align: center;margin-top: 60rpx;}
	.wenben_2{position: relative;text-align: center;margin-top: 160rpx;color: #808080;font-weight: 600;justify-content:center;
		view{background: #fff;position: relative;z-index: 111;padding: 0 30rpx;}
	}
	.wenben_2:before{position: absolute;content: '';width: 100%;bottom: 20rpx;height: 4rpx;background: #e0e0e0;left: 0;}
	.login_fangshi{padding-top: 50rpx;
		view{flex: 1;text-align: center;}
	}
	.btn-info{
	  display: flex;
	  align-items: center;
	  justify-content: center;margin-top: 100rpx;
	  width: 100%;
	  height: 100rpx;
	  .btn{
	    display: flex;
	    align-items: center;
	    justify-content: center;
	    width: 100%;
	    height: 100rpx;
	    background: linear-gradient(to right,$base,$change-clor);
	    border-radius: 100rpx;
	    color: #FFFFFF;
	    font-size: 28rpx;
	    opacity: 0.4;
	  }
	}
</style>
